import { call, put } from 'redux-saga/effects'
import { getTodoList } from '@api/home'

export function* fetchTable0({ payload }: actionType) {
  try {
    yield put({ type: 'G/ON_pLoading' })
    const { data } = yield call(getTodoList, payload)
    yield put({ type: 'G/OFF_pLoading' })
    yield put({ type: 'HOME/setupTable0', payload: data })
  } catch (error) {
    yield put({ type: 'REQUEST_FAILED', error })
  }
}

export function* fetchTable1({ payload }: actionType) {
  try {
    yield put({ type: 'G/ON_pLoading' })
    const { data } = yield call(getTodoList, payload)
    yield put({ type: 'G/OFF_pLoading' })
    yield put({ type: 'HOME/setupTable1', payload: data })
  } catch (error) {
    yield put({ type: 'REQUEST_FAILED', error })
  }
}
